package com.spark.controller;

import com.spark.service.RedisDemoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author sc
 * @DATE 2024/5/23 10:38
 * @Description:
 * @Version 1.0
 */
@RequiredArgsConstructor
@RestController
public class RedisDemoController {

    private final RedisDemoService redisDemoService;

    /**
     *  测试缓存
     * @param id
     * @return
     */
    @GetMapping("/testcache/{id}")
    public Object testCache(@PathVariable("id") String id) {
        return redisDemoService.getData(id);
    }

    /**
     *  更新缓存
     * @param id
     * @return
     */
    @GetMapping("/testcacheupdate/{id}")
    public Object testCacheUpdate(@PathVariable("id") String id) {
        return redisDemoService.updateData(id);
    }

    /**
     *  删除缓存
     * @param id
     */
    @GetMapping("/testcachedelete/{id}")
    public void testCacheDelete(@PathVariable("id") String id) {
        redisDemoService.deleteData(id);
    }

}
